package top.api.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.api.common.ResUlt;
import top.api.domain.dto.LoginDto;
import top.api.service.LoginServiceImpl;

@Slf4j
@RestController
@Api(tags = "登录")
@Validated
@RequiredArgsConstructor
public class LoginController {
    private final LoginServiceImpl loginService;

    @PostMapping("/h5Login")
    @SaIgnore
    @ApiOperation("网页登录")
    public ResUlt<?> h5Login(@RequestBody LoginDto loginDto){
        return loginService.h5Login(loginDto);
    }


    @GetMapping("/checkLogin")
    @SaIgnore
    @ApiOperation("检测是否登录")
    public ResUlt<?> checkLogin(){
        return loginService.checkLogin();
    }


    @GetMapping("/logOut")
    @SaIgnore
    @ApiOperation("退出登录")
    public ResUlt<?> logOut(){
        return loginService.logOut();
    }
}
